//
//  LYZRecommendCategoryCell.m
//  01-百思不得姐
//
//  Created by 李昱铮 on 16/8/25.
//  Copyright © 2016年 LYZ. All rights reserved.
//

#import "LYZRecommendCategoryCell.h"
#import "LYZRecommendCategory.h"

@interface LYZRecommendCategoryCell ()
/** 选中时显示的指示器控件 */
@property (weak, nonatomic) IBOutlet UIView *selectedIndicator;
@end

@implementation LYZRecommendCategoryCell

- (void)awakeFromNib {
      self.backgroundColor = LYZRGBColor(244, 244, 244);
      self.selectedIndicator.backgroundColor = LYZRGBColor(219, 21, 26);
    
      // 当cell的selection为None时, 即使cell被选中了, 内部的子控件也不会进入高亮状态
//    self.textLabel.highlightedTextColor = LYZRGBColor(219, 21, 26);    

}

- (void)setCategory:(LYZRecommendCategory *)category
{
    _category = category;
    self.textLabel.text = category.name;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    //重新调整内部textlable的frame
    self.textLabel.y = 2;
    self.textLabel.height = self.contentView.height - 2 * self.textLabel.y;
}
/**
 *  可以在这个方法中监听Cell的选中和取消选中
 */
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    self.selectedIndicator.hidden = !selected;
    self.textLabel.textColor = selected ? self.selectedIndicator.backgroundColor: LYZRGBColor(78, 78, 78);
    
}

@end
